﻿<UserControl
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:vf="clr-namespace:Visifire.Charts;assembly=SLVisifire.Charts"
    xmlns:converter="clr-namespace:VisualStock.Infrastructure.Converters;assembly=VisualStock.Infrastructure"
    mc:Ignorable="d"
    x:Class="VisualStock.Modules.StockMarket.HistoricalData.HistoricalDataChartView"
    d:DesignHeight="600" d:DesignWidth="800">

    <UserControl.Resources>
        <converter:EnumToStringConverter x:Key="EnumToStringConverter"/>

        <vf:DataMappingCollection x:Key="DataMappingCollection">
            <vf:DataMapping MemberName="AxisXLabel" Path="QuoteDateString"/>
            <vf:DataMapping MemberName="XValue" Path="RelativeXValue"/>
            <vf:DataMapping MemberName="YValue" Path="RelativeYValue"/>
            <vf:DataMapping MemberName="Open" Path="OpeningPrice"/>
            <vf:DataMapping MemberName="Close" Path="ClosingPrice"/>
            <vf:DataMapping MemberName="High" Path="HighestPrice"/>
            <vf:DataMapping MemberName="Low" Path="LowestPrice"/>
        </vf:DataMappingCollection>

        <vf:DataMappingCollection x:Key="DataMappingCollection2">
            <vf:DataMapping MemberName="AxisXLabel" Path="QuoteDateString"/>
            <vf:DataMapping MemberName="XValue" Path="RelativeXValue"/>
            <vf:DataMapping MemberName="YValue" Path="Volume"/>
        </vf:DataMappingCollection>

        <Style TargetType="vf:DataSeries" x:Key="DataSeriesStyle">
            <Setter Property="LineThickness" Value="1"/>
            <Setter Property="MarkerSize" Value="6"/>
            <Setter Property="MarkerEnabled" Value="false"/>
            <Setter Property="MovingMarkerEnabled" Value="true"/>
        </Style>

        <LinearGradientBrush x:Key="PNButtonForeground" EndPoint="0.5,1" StartPoint="0.5,0">
            <GradientStop Color="#FFD2FFD2" Offset="1"/>
            <GradientStop Color="Black"/>
        </LinearGradientBrush>
    </UserControl.Resources>

    <Grid x:Name="LayoutRoot">

        <Grid x:Name="ChartsGrid" Margin="15,5">
            <Grid.RowDefinitions>
                <RowDefinition Height="*"/>
                <RowDefinition Height="Auto"/>
            </Grid.RowDefinitions>

            <vf:Chart x:Name="MainChart" Grid.Row="0" BorderThickness="0" Background="{x:Null}" View3D="{Binding Path=Settings.View3D}">
                <vf:Chart.AxesX>
                    <vf:Axis ValueFormatString="dd/MM/yy" Interval="5"/>
                </vf:Chart.AxesX>
                <vf:Chart.AxesY>
                    <vf:Axis StartFromZero="false" Title="Quotes"/>
                </vf:Chart.AxesY>

                <vf:Chart.Series>
                    <vf:DataSeries DataSource="{Binding CurrentDataCollections[0]}" LegendText="{Binding CurrentSymbolList[0]}"
    						Style="{StaticResource DataSeriesStyle}" DataMappings="{StaticResource DataMappingCollection}" 
                            RenderAs="{Binding Path=Settings.PrimaryChartType,Converter={StaticResource EnumToStringConverter}}"/>

                    <vf:DataSeries DataSource="{Binding CurrentDataCollections[1]}" LegendText="{Binding CurrentSymbolList[1]}"
    						Style="{StaticResource DataSeriesStyle}" DataMappings="{StaticResource DataMappingCollection}"
                            RenderAs="{Binding Path=Settings.PrimaryChartType,Converter={StaticResource EnumToStringConverter}}"/>

                    <vf:DataSeries DataSource="{Binding CurrentDataCollections[2]}" LegendText="{Binding CurrentSymbolList[2]}"
    						Style="{StaticResource DataSeriesStyle}" DataMappings="{StaticResource DataMappingCollection}"
                            RenderAs="{Binding Path=Settings.PrimaryChartType,Converter={StaticResource EnumToStringConverter}}"/>

                    <vf:DataSeries DataSource="{Binding CurrentDataCollections[3]}" LegendText="{Binding CurrentSymbolList[3]}"
    						Style="{StaticResource DataSeriesStyle}" DataMappings="{StaticResource DataMappingCollection}"
                            RenderAs="{Binding Path=Settings.PrimaryChartType,Converter={StaticResource EnumToStringConverter}}"/>

                    <vf:DataSeries DataSource="{Binding CurrentDataCollections[4]}" LegendText="{Binding CurrentSymbolList[4]}"
    						Style="{StaticResource DataSeriesStyle}" DataMappings="{StaticResource DataMappingCollection}"
                            RenderAs="{Binding Path=Settings.PrimaryChartType,Converter={StaticResource EnumToStringConverter}}"/>
                </vf:Chart.Series>
            </vf:Chart>

            <!--For volumn display-->
            <vf:Chart x:Name="ExtendedChart" Grid.Row="1" BorderThickness="0" View3D="{Binding Path=Settings.View3D}" UniqueColors="false" Background="{x:Null}" Height="150" Visibility="{Binding Path=Settings.IsSecondaryChartVisible}">
                <vf:Chart.AxesX>
                    <vf:Axis ValueFormatString="dd/MM/yy" Interval="5"/>
                </vf:Chart.AxesX>
                <vf:Chart.AxesY>
                    <vf:Axis StartFromZero="false" ScalingSet="1000,K;1000,M" Title="Volume"/>
                </vf:Chart.AxesY>

                <vf:Chart.Series>
                    <vf:DataSeries DataSource="{Binding CurrentDataCollections[0]}" LegendText="{Binding CurrentSymbolList[0]}"
    						DataMappings="{StaticResource DataMappingCollection2}" LineThickness="1"
                            RenderAs="{Binding Path=Settings.SecondaryChartType,Converter={StaticResource EnumToStringConverter}}"/>
                </vf:Chart.Series>
            </vf:Chart>
        </Grid>
    </Grid>
</UserControl>
